package com.itany.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itany.dao.LoopDao;
import com.itany.entity.Loop;
import com.itany.entity.ManagerUser;
import com.itany.entity.User;
import com.itany.service.LoopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.print.attribute.standard.PDLOverrideSupported;
import java.util.List;

/**
 * Author:yaozhiyuan0117@163.com
 * Time:2019/12/21 14:35
 * Describe:
 * version:1.0
 */
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class LoopServiceImpl implements LoopService {


    @Autowired
    private LoopDao loopDao;

    @Override
    public void addLoop(Loop loop) {
        loopDao.insertLoop(loop);
    }

    @Override
    public PageInfo<Loop> findByPage(Integer page, Integer rows) {

        PageHelper.startPage(page,rows);
        List<Loop> users = loopDao.selectByPage();
        PageInfo<Loop> pageInfo = new PageInfo<>(users);
        return pageInfo;
    }

    @Override
    public void modifyStatus(Loop loop) {
        loopDao.updateStatus(loop);
    }

    @Override
    public void delete(Integer id) {
        loopDao.delete(id);
    }
}
